package com.ttg.web.task.tagDateEdit;

import com.ttg.common.entities.BaseResult;
import com.ttg.common.exception.BaseException;
import com.ttg.web.service.ManageTagInfoService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class TagBindBackUpTaskHandler {


    @Autowired
    private ManageTagInfoService manageTagInfoService;

    @Async
    @XxlJob("TagBindBackUpTaskHandler")
    public ReturnT<String> execute() {
        log.info("【TagBindBackUpTask 商户命中标签备份任务】 start");
        boolean b = false;
        try {
            BaseResult baseResult = manageTagInfoService.backUp();
        } catch (Exception e) {
            log.error("异常调度异常：{}",e.getMessage());
            XxlJobContext.getXxlJobContext().setHandleCode(ReturnT.FAIL_CODE);
            XxlJobContext.getXxlJobContext().setHandleMsg("执行异常，请联系管理员查询相关日志" + e.getMessage());
            throw new BaseException("异常调度异常",e.getLocalizedMessage());
        }
        log.info("【TagBindBackUpTask 商户命中标签备份任务】 end=====>{}",b);
        return ReturnT.SUCCESS;
    }
}
